package cloud.maque.admin.controller;

import cloud.maque.admin.annotations.MaquerManager;
import cloud.maque.admin.domain.entity.MqComboMenu;
import cloud.maque.admin.service.MqComboMenuService;
import cloud.maque.framework.common.response.ResponseBodyVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhuyf
 * @date 2023/5/13 18:01
 */
@RestController
@RequestMapping(value = "/combo-menu")
@Api(tags = "运维-租户套餐菜单")
public class ComboMenuController {


    @Resource
    private MqComboMenuService comboMenuService;

    /**
     * 保存
     *
     * @date 2023/05/13
     **/
    @PostMapping("/save/{id}")
    @ApiOperation(value = "新增或修改")
    @MaquerManager
    public ResponseBodyVo<List<MqComboMenu>> insert(@RequestBody List<String> menuids, @PathVariable("id") String comboId) {
        return ResponseBodyVo.Success(comboMenuService.saveMenu(comboId, menuids));
    }


    /**
     * 查询 根据套餐 id 查询
     *
     * @date 2023/05/13
     **/
    @GetMapping("/load/{id}")
    @ApiOperation(value = "查询单个")
    public ResponseBodyVo<List<MqComboMenu>> load(@PathVariable("id") String comboId) {
        return ResponseBodyVo.Success(comboMenuService.getMenus(comboId));
    }


}
